/*
//  JTPerlInterface.h
//  Agate Rule Tester
//
//  Created by Jim Turner on 11/20/05.

License: GNU General Public License
This program is free software; you can redistribute it and/or modify it under 
the terms of the GNU General Public License as published by the Free Software 
Foundation; either version 2 of the License, or (at your option) any later 
version.

This program is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 
details.

You should have received a copy of the GNU General Public License along 
with this program; if not, write to the Free Software Foundation, Inc., 
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
http://www.gnu.org/licenses/licenses.html#GPL

*/

#import <Cocoa/Cocoa.h>
#import <Foundation/Foundation.h>
#import <CamelBones/CamelBones.h>
#import <CamelBones/AppMain.h>

@interface JTPerlInterface : NSObject 
{
	CBPerl *perl;
	id perlObj;
	
	NSString *extractionError;
	BOOL      lastExtractionStatus;
}

- (void) dealloc;
- (NSString *) applyRegex:(NSString *)regex onText:(NSString *)text;
- (int) matchRegex:(NSString *)regex onText:(NSString *)text;
- (NSString *) applyFind:(NSString *)find 
			  andReplace:(NSString *)replace 
			      onText:(NSString *)text 
		   caseSensitive:(BOOL) casesensitive 
			replaceFirst:(BOOL) replacefirst
			 replaceLast:(BOOL) replacelast
			  exhaustive:(BOOL) exhaustive;
- (NSString *) showDTMnemonics:(NSString *)text;
- (NSString *) extractStoryText:(NSString *)rawText;
- (BOOL) wasLastExtractionSuccessful;
- (NSString *) extractionError;
- (NSString *) testRegex:(NSString *)regex;
- (NSString *) convertTranslationToInDesign:(NSString *)text;
- (NSString *) unicodeToMnemonic:(NSString *)text;
@end

/* I probably should have prefaced all of these with p_ (as like-named
   functions in Cocoa can interfere with these guys).  Maybe I'll 
   fix that someday 
*/
@interface NSObject (MyPerlClassMethods)
- (id) parseRegex:(id)pattern onText:(id)text exhaustive:(BOOL)exhaustive;
- (id) p_replaceLastWithFind:(id)fixedFind withReplace:(id)fixedReplace onText:(id)text caseSensitive:(BOOL)casesensitive;
- (int) p_matchRegex:(id)pattern onText:(id)text;
- (id) p_showDTMnemonics:(id)text;
//- (id) replacePlaceholders:(id)regex;
- (id) extractStoryText:(id)rawText;
- (id) escapeRegexCharactersInExpression:(id)pattern;
- (id) escapeRegexCharactersInReplacement:(id)pattern;
- (id) doRegexTest:(id)pattern;
- (id) p_mnemonicToUnicode:(id)text;
- (id) p_unicodeToMnemonic:(id)text;
- (id) p_unicodeToInDesign:(id)text;
@end
